<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <title>个人中心</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <script src="js/rem.js"></script>
    <script src="js/jquery.min.js" type="text/javascript"></script>
    <link rel="stylesheet" type="text/css" href="css/base.css" />
    <link rel="stylesheet" type="text/css" href="css/page.css" />
    <link rel="stylesheet" type="text/css" href="css/all.css" />
    <link rel="stylesheet" type="text/css" href="css/mui.min.css" />
    <link rel="stylesheet" type="text/css" href="css/loaders.min.css" />
    <link rel="stylesheet" type="text/css" href="iconfont/iconfont.css" />



    <script src="js/reqrcode.js"></script>



    <style>
        [v-cloak] {
            display: none;
            opacity: 0;
        }
    </style>
</head>

<body>
    <!--header star-->
    <header class="mui-bar mui-bar1 mui-bar-nav mui-bar-nav1" style="z-index:1;">
        <!-- <a class="back-btn" href="javascript:history.go(-1)">
	            <i class="iconfont icon-fanhui"></i>
	        </a> -->
        <div class="mui-title" style="z-index:1;">浙江同济职业技术学院</div>
    </header>
    <!--header end-->

    <div class="warp clearfloat" id='app' v-cloak>
        <div class="h-top clearfloat box-s">
            <div class="todo__btn" @click="goTodo">待办信息</div>
            <div class="ge-back"><img src="img/text-bck.png"></div>
            <div class="mui-tus">
                <div class="huiyuan-text">
                    <img src="img/touxiang.png" />
                    <!-- 	<div class="content clearfloat">
							<p class="hname">王小二</p>
							<p class="hpthy">普通管理员</p>
						</div> -->
                    <a class="content clearfloat" style="font-size: 0.5rem; color: #fff;display: block;" href="javascript:void(0);">
            {{this.user.name}}
          </a>

                </div>

                <ul>
                    <li>
                        <a href="javascript:void(0);">
                            <p>{{userData.AppointmentInstrumentCount}}台</p>
                            <span>预约设备</span>
                        </a>
                    </li>
                    <span class="right-lines"></span>
                    <li>
                        <a href="javascript:void(0);">
                            <p>{{userData.receiveCount}}台</p>
                            <span>领用设备</span>
                        </a>
                    </li>
                    <span class="right-lines"></span>
                    <li>
                        <a href="javascript:void(0);">
                            <p>{{userData.examRecordCount}}</p>
                            <span>考试次数</span>
                        </a>
                    </li>
                </ul>

            </div>
        </div>

        <!-- <div class="swiper-text clearfloat">
            <span class="fl vip-span">
					<svg class="icon vip-s" aria-hidden="true">
					  <use xlink:href="#icon-94"></use>
					</svg>
          
					</span>
            <a class="fr vip-kai" href="javascript:void(0);" >前往</a>
        </div> -->
        <div class="four-text clearfloat">
            <ul class="four-ul">
                <li style="background: linear-gradient(to left bottom, rgba(82, 86, 255, 0.5), rgba(82, 86, 255, 0.9));margin-right: 0.35rem;">
                    <a href="yy/demos/main/forms.html">
                        <div class="back-text">
                            <div class="box-text">
                                <i class="iconfont zise icon-4"></i>
                                <p>我要预约</p>
                            </div>
                            <div class="box-text_2">
                                <p>已经预约数量</p>
                                <p>{{userData.appointmentCount}}</p>
                            </div>
                        </div>
                    </a>
                </li>
                <li style="background: linear-gradient(to left bottom, rgba(254, 81, 150, 0.5), rgba(254, 81, 150, 0.9));">
                    <van-uploader v-model="fileList" :after-read="afterRead" accept="image/*" capture="camera" :preview-image='false'>
                        <!-- <van-button icon="plus" type="primary">上传文件</van-button> -->

                        <div class="back-text" icon="plus" type="primary">
                            <div class="box-text">
                                <i class="iconfont hongse icon-08_zizhanghaoguanli"></i>
                                <p>我要领用</p>
                            </div>
                            <div class="aidou-text">
                                <div class="box-text_2">
                                    <p>已领用</p>
                                    <p>{{userData.receiveCount}}</p>
                                </div>
                                <div class="box-text_2">
                                    <p>归还数</p>
                                    <p>{{userData.receiveEdCount}}</p>
                                </div>
                            </div>
                        </div>
                    </van-uploader>
                </li>

            </ul>
            <ul>
                <li style="background: linear-gradient(to left bottom, rgba(255, 177, 153, 0.5), rgba(255, 177, 153, 0.9)); margin-right: 0.35rem;">
                    <van-uploader v-model="fileListTest" :before-read="beforeRead" :after-read="afterReadTest" accept="image/*" capture="camera" :preview-image='false'>
                    <!-- <a href="jiancha/index.html"> -->
                        <div class="back-text">
                            <div class="box-text">
                                <i class="iconfont fense icon-zhanghuguanli"></i>
                                <p>安全检查</p>
                            </div>

                            <div class="box-text_2">
                                <p>检测次数</p>
                                <p>{{userData.checkDayCount}}</p>
                            </div>
                        </div>
                    <!-- </a> -->
                    </van-uploader>
                </li>
                <li style="background: linear-gradient(to left bottom, rgba(0, 114, 255, 0.5), rgba(0, 114, 255, 0.9));">
                    <a href="ks/catemain-errtm.html">
                        <div class="back-text">
                            <div class="box-text">
                                <i class="iconfont lanse icon-youhuiquan"></i>
                                <p>学习考试</p>
                            </div>
                            <div class="box-text_2">
                                <p>已考试次数</p>
                                <p>{{userData.examRecordCount}}</p>
                            </div>

                        </div>
                    </a>
                </li>
            </ul>
        </div>
        <div class="cashlist clearfloat">
            <ul>
                <li class="box-s">
                    <a href="javascript:void(0);">
                        <van-uploader v-model="fileList2" :before-read="beforeRead" :after-read="afterReadbing" accept="image/*" capture="camera" :preview-image='false'>
                            <p style="width: 260px;"><i class="iconfont icon-zhanghao"></i>绑定设备</p>
                        </van-uploader>
                        <i class="iconfont icon-jiantou1"></i>
                    </a>
                </li>
                <li class="box-s">
                    <a href="javascript:void(0);">
                        <van-uploader v-model="fileList3" :after-read="afterReadGui" accept="image/*" capture="camera" :preview-image='false'>
                            <p style="width: 260px;"><i class="iconfont icon-zhanghao"></i>归还设备</p>
                        </van-uploader>
                        <i class="iconfont icon-jiantou1"></i>
                    </a>
                </li>
                <li class="box-s">
                    <a href="yy/demos/main/tables.html">
                        <p><i class="iconfont icon-tubiao201"></i>领用归还记录</p>
                        <i class="iconfont icon-jiantou1"></i>
                    </a>
                </li>
                <li class="box-s">
                    <a href="yy/demos/main/tables2.html">
                        <p><i class="iconfont icon-zhanghao"></i>预约记录</p>
                        <i class="iconfont icon-jiantou1"></i>
                    </a>
                </li>
                <li class="box-s">
                    <a href="yy/demos/main/tables3.html">
                        <p><i class="iconfont icon-dailizhanghaoguanli"></i>检查记录</p>
                        <i class="iconfont icon-jiantou1"></i>
                    </a>
                </li>
                <li class="box-s">
                    <a href="ks/catemain-errtm2.html">
                        <p><i class="iconfont icon-zhanghao"></i>考试记录</p>
                        <i class="iconfont icon-jiantou1"></i>
                    </a>
                </li>

            </ul>
        </div>
        <van-dialog v-model="show" :before-close='findinstrument' title="请输入设备编号" @cancel="show=false" show-cancel-button>
            <van-field v-model="instrumentNum" size="large" label="" placeholder="请输入设备编号" ></van-field>
            <van-field v-model="instrumentName" size="large" label="" placeholder="请输入设备名称" ></van-field>
        </van-dialog>

        <a href="login.html" class="center-btn db ra3">退出登录</a>
    </div>

    <script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
    <script src="js/mui.min.js"></script>
    <script type="text/javascript" src="js/hmt.js"></script>
    <!-- <script src="iconfont/iconfont.js"></script> -->


</body>


<!-- <link rel="stylesheet" href="js/iview/iview.css"> -->




<script src="js/vue/vue.js"></script>
<!-- <script src="js/iview/iview.min.js"></script> -->
<script src="js/jsCookie/js.cookie.min.js"></script>
<script src="js/axios/axios.min.js"></script>

<script src="https://cdn.jsdelivr.net/npm/vant@2.12/lib/vant.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vant@2.12/lib/index.css" />





<script>
    var app = new Vue({
        el: '#app',
        data: {
            user: {},
            userINfo: {},
            siyangyuan: false,
            shouyi: false,
            sicaoList: [],
            sum: 0,
            modal1: false,
            chengIndex: [],
            xxx: 223,
            fileList: [],
            fileListTest: [],
            show: false,
            fileList2: [],
            fileList3: [],
            instrumentNum: '',
            instrumentName: '',
            instrumentId: '',
            imgMsg: '',
            userData: {
                AppointmentInstrumentCount: 0,
                appointmentCount: 21,
                checkDayCount: 0,
                examRecordCount: 0,
                receiveEdCount: 0,
                receiveCount: 0
            },
            t: '',
        },
        methods: {
            isPC () {
                var system ={
                win : false,
                mac : false,
                xll : false
                };
                //检测平台
                var p = navigator.platform;
                system.win = p.indexOf("Win") == 0;
                system.mac = p.indexOf("Mac") == 0;
                system.x11 = (p == "X11") || (p.indexOf("Linux") == 0);
                //跳转语句，如果是手机访问就自动跳转到caibaojian.com页面
                return !(!(system.win||system.mac||system.xll) && /(iPhone|iPad|iPod|iOS|Android)/i.test(navigator.userAgent))	
            },
            goTodo() {
                window.location.href = '/todo/todoList.html'
            },
            getCookieUser() {
                let userJson = Cookies.get('userInfo');
                if (!userJson) {
                    this.$notify({
                        type: 'danger',
                        message: '请先登录'
                    });
                    window.location.href = '/login.html'
                    return
                }
                this.user = JSON.parse(userJson)
                if (!this.user) {
                    this.$notify({
                        type: 'danger',
                        message: '请先登录'
                    });
                    window.location.href = '/login.html'
                    return
                }
                this.getUserData()

            },
            tuichu() {
                Cookies.remove('userInfo')
                Cookies.remove('UserLogin')
                window.location.href = '/intro.html'
            },
            GetQueryString(name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
                var r = window.location.search.substr(1).match(reg);
                if (r != null) return unescape(r[2]);
                return null;
            },
            S4() {
                return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
            },
            guid() {
                return (this.S4() + this.S4() + "-" + this.S4() + "-" + this.S4() + "-" + this.S4() + "-" + this.S4() + this.S4() + this.S4());
            },
            getDate() {
                let date = new Date()
                let y = date.getFullYear()
                let MM = date.getMonth() + 1
                MM = MM < 10 ? ('0' + MM) : MM
                let d = date.getDate()
                d = d < 10 ? ('0' + d) : d
                let h = date.getHours()
                h = h < 10 ? ('0' + h) : h
                let m = date.getMinutes()
                m = m < 10 ? ('0' + m) : m
                let s = date.getSeconds()
                s = s < 10 ? ('0' + s) : s
                return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s
            },
            addQr(code) {
                let formData = new FormData();
                formData.append("instrumentQRId", this.findStr('id', code));
                // formData.append("instrumentQRId", code);
                //10.10.0.164
                //81.68.101.36
                //81.68.101.36:9012
                axios
                    .post(
                        "http://10.11.41.128:30010/insrtumentReceive/add?ticket=" + Cookies.get('ticket'),
                        formData, {
                            headers: {
                                "Content-Type": "multipart/form-data",
                                "token": this.user.token,
                            },
                        }
                    )
                    .then(res => {
                        if (res.data === null || res.data === " ") return;
                        if (res.data.status === 1) {
                            console.log(res.data)
                            this.$notify({
                                type: 'success',
                                message: '领用成功'
                            });
                            this.getUserData()
                        } else {
                            this.$notify({
                                type: 'danger',
                                message: '加载失败' + res.data.msg
                            });
                            if (res.data.msg === "未登录") {
                                window.location.href = "login.html"
                            }
                        }
                    });
            },
            QrToTest(id) {
                let formData = new FormData();
                formData.append("testId", id);
                formData.append("userId", this.user.id);
                //10.10.0.164
                //81.68.101.36
                //81.68.101.36:9012
                axios
                    .post(
                        "http://10.11.41.128:30010/check/findCheckUserScope?ticket=" + Cookies.get('ticket'),
                        formData, {
                            headers: {
                                "Content-Type": "multipart/form-data",
                                "token": this.user.token,
                            },
                        }
                    )
                    .then(res => {
                        if (res.data === null || res.data === " ") return;
                        if (res.data.status === 1 && res.data.data && res.data.data.dataList && res.data.data.dataList.length > 0) {
                            console.log('获取房间id', res.data)
                            window.location.href = `jiancha/index.html?testId=${id}`
                        } else {
                            this.$notify({
                                type: 'danger',
                                message: '获取房间失败'
                            });
                            if (res.data.msg === "未登录") {
                                window.location.href = "login.html"
                            }
                        }
                    });
            },
            afterRead(file) {
                let _that = this
                file.status = 'uploading'
                file.message = '上传中...'
                    // 此时可以自行将文件上传至服务器
                qrcode.decode(this.getObjectURL(file.file));
                qrcode.callback = function(imgMsg) {
                    file.status = 'done';
                    file.message = '上传完成';
                    console.log('上传文件', imgMsg)
                    _that.addQr(imgMsg)
                }

            },
            afterReadTest(file) {
                let _that = this
                file.status = 'uploading'
                file.message = '上传中...'
                    // 此时可以自行将文件上传至服务器
                qrcode.decode(this.getObjectURL(file.file));
                qrcode.callback = function(imgMsg) {
                    file.status = 'done';
                    file.message = '上传完成';
                    console.log('上传文件', imgMsg)
                    _that.QrToTest(imgMsg)
                }

            },
            beforeRead() {
                if (this.isPC()) {
                    this.$notify({
                        type: 'danger',
                        message: '请在手机端操作'
                    });
                    return false;
                }
                return true;
            },
            addQrGui(code) {
                let formData = new FormData();
                // formData.append("randow", Math.random());
                // formData.append("instrumentQRId", id);
                formData.append("instrumentId", this.findStr('id', code));
                // formData.append("instrumentId", code);
                // formData.append("userId", this.user.id);
                axios
                    .post(
                        "http://10.11.41.128:30010/insrtumentReceive/revert?ticket=" + Cookies.get('ticket'),
                        formData, {
                            headers: {
                                "Content-Type": "multipart/form-data",
                                "token": this.user.token,
                            },
                        }
                    )
                    .then(res => {
                        if (res.data === null || res.data === " ") return;
                        if (res.data.status === 1) {
                            console.log(res.data)
                            this.$notify({
                                type: 'success',
                                message: '归还成功'
                            });
                        } else {
                            this.$notify({
                                type: 'danger',
                                message: '加载失败' + res.data.msg
                            });
                            if (res.data.msg === "未登录") {
                                window.location.href = "login.html"
                            }
                        }
                    });
            },
            afterReadGui(file) {
                let _that = this
                file.status = 'uploading'
                file.message = '上传中...'
                    // 此时可以自行将文件上传至服务器
                qrcode.decode(this.getObjectURL(file.file));
                qrcode.callback = function(imgMsg) {
                    file.status = 'done';
                    file.message = '上传完成';
                    _that.addQrGui(imgMsg)
                }

            },
            findStr(name, code) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
                var r = code.substr(1).match(reg);
                return unescape(r[2]);
            },
            findinstrument(action, done) {
                if (action === 'cancel') {
                    done()
                    return
                }
                this.instrumentName = '';
                let formData = new FormData();
                formData.append("num", this.instrumentNum);
                axios
                    .post(
                        "http://10.11.41.128:30010/insrtument/findInstrument?ticket=" + Cookies.get('ticket'),
                        formData, {
                            headers: {
                                "Content-Type": "multipart/form-data",
                                "token": this.user.token,
                            },
                        }
                    )
                    .then(res => {
                        if (res.data === null || res.data === " ") return;
                        if (res.data.status === 1) {
                            console.log(res.data)
                            if (res.data.data.dataList.length > 0) {
                                this.show = false
                                this.$notify({
                                    type: 'success',
                                    message: '请求成功'
                                });
                                this.addQrbind(res.data.data.dataList[0].ID, done)
                            } else {
                                done(false)
                                this.$notify({
                                    type: 'danger',
                                    message: '没有查询到对应设备编号！'
                                });
                                this.addQrbind('', done)
                            }
                        } else {
                            this.$notify({
                                type: 'danger',
                                message: '加载失败' + res.data.msg
                            });
                            done(false)
                            if (res.data.msg === "未登录") {
                                window.location.href = "login.html"
                            }
                        }
                    });
            },
            addQrbind(instrumentId, done) {
                let formData = new FormData();
                formData.append("id", this.findStr('id', this.imgMsg));
                formData.append("instrumentId", instrumentId);
                formData.append("instrumentNum", this.instrumentNum);
                formData.append("instrumentName", this.instrumentName);
                axios
                    .post(
                        "http://10.11.41.128:30010/insrtumentQR/bind?ticket=" + Cookies.get('ticket'),
                        formData, {
                            headers: {
                                "Content-Type": "multipart/form-data",
                                "token": this.user.token,
                            },
                        }
                    )
                    .then(res => {
                        if (res.data === null || res.data === " ") return;
                        if (res.data.status === 1) {
                            console.log(res.data)
                            this.$notify({
                                type: 'success',
                                message: '绑定成功！'
                            });
                            this.instrumentNum = '',
                            this.instrumentName = '';
                            this.instrumentId = '';
                            done()
                        } else {
                            console.log(res.data)
                            done(false)
                            this.$notify({
                                type: 'danger',
                                message: '加载失败' + res.data.msg
                            });
                            if (res.data.msg === "未登录") {
                                window.location.href = "login.html"
                            }
                        }
                    });
            },
            afterReadbing(file) {
                let _that = this
                file.status = 'uploading'
                file.message = '上传中...'
                    // 此时可以自行将文件上传至服务器
                qrcode.decode(this.getObjectURL(file.file));
                qrcode.callback = function(imgMsg) {
                    file.status = 'done';
                    file.message = '上传完成';
                    _that.show = true
                    _that.imgMsg = imgMsg
                }

            },
            getObjectURL(file) {
                var url = null;
                if (window.createObjectURL != undefined) { // basic
                    url = window.createObjectURL(file);
                } else if (window.URL != undefined) { // mozilla(firefox)
                    url = window.URL.createObjectURL(file);
                } else if (window.webkitURL != undefined) { // webkit or chrome
                    url = window.webkitURL.createObjectURL(file);
                }
                return url;
            },
            getUserData() {
                let formData = new FormData();
                formData.append("createId", this.user.id);
                axios
                    .post(
                        "http://10.11.41.128:30010/user/findStatistic?ticket=" + Cookies.get('ticket'),
                        formData, {
                            headers: {
                                "Content-Type": "multipart/form-data",
                                "token": this.user.token,
                            },
                        }
                    )
                    .then(res => {
                        if (res.data === null || res.data === " ") return;
                        if (res.data.status === 1) {
                            console.log(res.data)
                            this.userData = res.data.data.data

                        } else {
                            this.$notify({
                                type: 'danger',
                                message: '加载失败' + res.data.msg
                            });
                            if (res.data.msg === "未登录") {
                                window.location.href = "login.html"
                            }
                        }
                    });
            },
        },
        mounted: function() {
            this.getCookieUser()
        }
    })
</script>

</html>